<template>
  <div class="goodsindex">
    <!-- 搜索条件 -->
    <el-row :gutter="20" class="goodsindex-queryInfo">
      <!-- 商品名称搜索 -->
      <el-col :xs="8" :sm="6" :md="6" :lg="4" :xl="4">
        <el-input
          class="goodsindex-queryInfo-li"
          v-model="queryInfo.account"
          clearable
          size="small"
          placeholder="请输入账号"
        ></el-input>
      </el-col>

      <el-col :xs="6" :sm="4" :md="3" :lg="2" :xl="2">
        <el-button
          type="primary"
          class="goodsindex-queryInfo-li"
          size="small"
          @click="initData"
          >搜索</el-button
        >
      </el-col>
    </el-row>
    <!-- 检索结果 -->
    <el-row :gutter="20" class="goodsindex-list">
      <el-col :span="24">
        <el-table
          :data="tableData.records"
          border
          size="small"
          style="width: 100%"
        >
          <el-table-column type="index" label="序" width="50">
          </el-table-column>
          <el-table-column
            prop="id"
            label="订单编号"
            width="180"
            :show-overflow-tooltip="true"
          >
          </el-table-column>
          <el-table-column prop="userId" label="用户ID " width="150">
          </el-table-column>
          <el-table-column
            prop="beforMoney"
            label="充值前总金额(元)"
            width="120"
          >
          </el-table-column>
          <!-- <el-table-column
            prop="beforRechargeAmount"
            label="充值前充值金额"
            width="140"
          >
          </el-table-column> -->
          <!-- <el-table-column
            prop="beforDisAmount"
            label="充值前优惠金额"
            width="180"
          >
          </el-table-column> -->
          <el-table-column prop="chargeMoney" label="充值金额(元)" width="120">
          </el-table-column>
          <el-table-column prop="disAmount" label="优惠金额(元)" width="120">
          </el-table-column>
          <el-table-column
            prop="afterMoney"
            label="充值后总金额(元)"
            width="120"
          >
          </el-table-column>
          <!-- <el-table-column
            prop="afterRechargeAmount"
            label="充值后充值总金额"
            width="140"
          >
          </el-table-column>
          <el-table-column
            prop="afterDisAmount"
            label="充值后优惠金额"
            width="140"
          >
          </el-table-column> -->

          <el-table-column
            prop="payTime"
            :formatter="dateFormat"
            label="充值时间"
            width="140"
          ></el-table-column>
          <el-table-column
            :formatter="charge"
            prop="payType"
            label="充值类型"
            width="140"
          ></el-table-column>
          <el-table-column
            prop="payId"
            label="第三方充值Id"
            width="140"
            :show-overflow-tooltip="true"
          ></el-table-column>
          <el-table-column
            prop="status"
            label="状态"
            :formatter="status"
            width="60"
          ></el-table-column>
          <el-table-column
            prop="endTime"
            :formatter="dateFormat"
            label="完成时间"
            width="140"
          ></el-table-column>
          <el-table-column
            :formatter="vip"
            prop="vip"
            label="会员等级"
            width="140"
          ></el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <!-- 分页 -->
    <el-row :gutter="20" class="goodsindex-list">
      <el-col :span="24" class="goodsindex-page-box">
        <el-pagination
          :hide-on-single-page="true"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryInfo.page"
          :page-sizes="[10, 20, 50, 100]"
          :page-size="queryInfo.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="tableData.total"
        >
        </el-pagination>
      </el-col>
    </el-row>

    <!-- delect -->
    <el-dialog title="提示" :visible.sync="selectUser" width="30%">
      <span
        >确定删除{{ selectUser ? `’${selectUser.storeName}‘` : "" }}吗?</span
      >
      <span slot="footer" class="dialog-footer">
        <el-button @click="selectUser = null">取 消</el-button>
        <el-button type="primary" @click="null">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import moment from "moment";
export default {
  data() {
    return {
      dialogVisible: false,
      queryInfo: {
        account: "",
        queryFromTime: "",
        queryToTime: "",
        page: 1,
        pageSize: 10,
      },
      selectUser: null,

      tableData: [],
    };
  },
  async created() {
    this.initData();
  },
  methods: {
    async initData() {
      let query = {
        ...this.queryInfo,
      };
      if (query.account == "") delete query.account;
      if (query.queryFromTime == "") delete query.queryFromTime;
      if (query.queryToTime == "") delete query.queryToTime;

      let list = await this.http.post("/payOrder/queryPage", {
        pageSize: this.queryInfo.pageSize,
        pageNo: this.queryInfo.page,
        query: query,
      });
      this.tableData = list.result;
    },
    handleSizeChange(size) {
      this.queryInfo.pageSize = size;
      this.initData();
    },
    handleCurrentChange(currentPage) {
      this.queryInfo.pageNo = currentPage;
      this.initData();
    },
    to(url) {
      this.$router.push({ path: url });
    },
    status(row) {
      if (row.status == 0) return "未完成";
      else return "完成";
    },
    charge(row) {
      if (row.payType == 0) return "用户钱包";
      if (row.payType == 1) return "现金";
      if (row.payType == 2) return "微信支付";
      if (row.payType == 4) return "邀请分润";
      if (row.payType == 3) return "微信订单支付";
      //       WALLET(0, "用户钱包"),
      // CASH(1, "现金"),
      // WX_MINA(2, "微信支付"),
      // REBATE(4,"邀请分润"),
      // WX_ORDER(3,"微信订单支付");
    },
    vip(row) {
      if (row.vip == 0) return "普通用户";
      if (row.vip == 1) return "普通会员";
      if (row.vip == 2) return "高级会员";
    },
    dateFormat(row, column) {
      var date = row[column.property];
      if (date == undefined) {
        return "";
      }
      return moment(date).format("YYYY-MM-DD HH:mm:ss");
    },
  },
};
</script>

<style scoped>
.goodsindex {
  width: 100%;
  min-height: 100%;
  padding: 15px;
  box-sizing: border-box;
}
/* 搜索 */
.goodsindex-queryInfo {
  margin-bottom: 10px;
}
.goodsindex-queryInfo-li {
  width: 100%;
  height: auto;
}
/* 列表 */
.goodsindex-list {
  width: 100%;
  height: auto;
  margin-bottom: 20px;
}
/* 分页 */
.goodsindex-page-box {
  width: 100%;
  height: auto;
  display: flex;
  justify-content: flex-end;
}
</style>